﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProjectWebNhac.BUS;
using ProjectWebNhac.DTO;

namespace ProjectWebNhac.GUI.User
{
    public partial class PLayListCuaToi : System.Web.UI.Page
    {
        PlaylistBus plbus = new PlaylistBus();
        NguoiDungDTO nddto = new NguoiDungDTO();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                loadplaylist();
            }
        }

        private void loadplaylist()
        {
            nddto = (NguoiDungDTO)Session["ThanhVien"];
            rePlaylist.DataSource = plbus.LayPlaylistTheoTaiKhoan(nddto.TaiKhoan);
            rePlaylist.DataBind();
        }

        protected void rePlaylist_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
                if (e.CommandName.Equals("Xoa"))
                {
                    int MaPlayList = int.Parse(e.CommandArgument.ToString());
                    plbus.xoaplaylist(MaPlayList);
                    loadplaylist();
                }
                if (e.CommandName.Equals("Edit"))
                {
                    int MaPlayList = int.Parse(e.CommandArgument.ToString());
                    Response.Redirect("EditPlaylist.aspx?MaPlaylist="+MaPlayList);
                }
        }
    }
}